package test6_8;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Test2 {

    public int findKthLargest (int[] array, int k) {

        HashMap<Integer, Integer> map = new HashMap<>();

        for (int i = 0; i < array.length; i++) {
        if (!map.containsKey(array[i])){
            map.put(array[i],i);
        }
        }

        Iterator<Map.Entry<Integer, Integer>> iterator = map.entrySet().iterator();
        int i=0;
        while (iterator.hasNext()) {
            Map.Entry<Integer, Integer> entry = iterator.next();
            if (i==k-1){
                return entry.getKey();
            }
            i++;
        }

        return 0;




    }

    public static void main(String[] args) {

        int[] arr={2,53,5,6};
        Test2 test2 = new Test2();
        System.out.println(test2.findKthLargest(arr, 2));
    }





}
